#include "mesh.h"

using namespace Kraw;

MeshSource::MeshSource() :
    numStreams(0),
    numVertices(0),
    numIndices(0),
    pStreams(0),
    pVertices(0),
    pIndices(0)
{
}

MeshSource::~MeshSource()
{
    Unload();
}

int MeshSource::GetVertexWidth()
{
    int vertexWidth = 0;
    for (int streamIdx = 0; streamIdx < numStreams; ++streamIdx)
        vertexWidth += pStreams[streamIdx].size;

    return vertexWidth;
}

void MeshSource::Unload()
{
    if (pStreams)
    {
        delete[] pStreams;
        pStreams = 0;
        numStreams = 0;
    }

    if (pVertices)
    {
        delete[] pVertices;
        pVertices = 0;
        numVertices = 0;
    }

    if (pIndices)
    {
        delete[] pIndices;
        pIndices = 0;
        numIndices = 0;
    }
}
